package demo2;

import java.util.ArrayList;
@SuppressWarnings({"all"})
public class test {
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new News("第一个新闻的主要的内容就是今天的天气很好，主要的内容就是今天的天气很好"));
        arrayList.add(new News("第二个新闻的主要的内容就是今天的天气很不不不不好，主要的内容就是今天的天气很好不"));
        int size=arrayList.size();
        //System.out.println(arrayList.getClass());
        for(int i=size-1;i>=0;i--){
            //System.out.println(arrayList.get(i));
            News news = (News)arrayList.get(i);
            System.out.println(processTitle(news.getTitle()));
        }
    }

    public static String processTitle(String title){
        if(title==null){
            return "";
        }
        if(title.length()>15){
            return title.substring(0,15)+".........";
        }
        else{
            return title;
        }
    }
}
@SuppressWarnings({"all"})
class News{
    private String content;
    private String title;

    public News(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public String toString() {
        return "News{" +
                "title='" + title + '\'' +
                '}';
    }
}
